package com.jieshuibao.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.jieshuibao.mapper.AttentionExMapper;
import com.jieshuibao.mapper.AttentionMapper;
import com.jieshuibao.model.db.Attention;
import com.jieshuibao.model.db.AttentionExample;
import com.jieshuibao.model.db.AttentionKey;
import com.jieshuibao.model.db.RedEnvelopesArticleUser;
import com.jieshuibao.model.domain.PagePhone;

@Service
public class AttentionService{
	
	@Resource
	private AttentionMapper attentionMapper;
	@Resource
	private AttentionExMapper attentionExMapper;
	
	public void addAttention(Attention attention) {
		attentionMapper.insertSelective(attention);
	}
	
	public void delAttentionByBeAttentionNum(AttentionKey key) {
		attentionMapper.deleteByPrimaryKey(key);
	}
	
	public void updateAttention(Attention attention) {
		attentionMapper.updateByPrimaryKeySelective(attention);
	}
	
	public Attention getAttentionByBeAttentionNum(AttentionKey key) {
		return attentionMapper.selectByPrimaryKey(key);
	}
	
	public List<Attention> getPageAttention(AttentionExample attentionExample) {
		return attentionMapper.selectPage(attentionExample);
	}
	
	public int countAttention(AttentionExample attentionExample) {
		return attentionMapper.countByExample(attentionExample);
	}
	//查询关注的人
	public List<RedEnvelopesArticleUser> getAttentionUsers(AttentionExample attentionExample){
		return attentionExMapper.selectAllAttentionUser(attentionExample);
	}
	
	public List<RedEnvelopesArticleUser> getUserFans(AttentionExample attentionExample){
		return attentionExMapper.selectAllUserFans(attentionExample);
	}
	
	public List<RedEnvelopesArticleUser> getUsers(PagePhone pagePhone){
		return attentionExMapper.selectAllUser(pagePhone);
	}
}
